# coding:utf-8
import pandas as pd
from pandas import Series, DataFrame

filename = './src/book_data.csv'

data = pd.read_csv(filename, encoding='gbk')[:360]


index = [index for index in range(0,360,30)]
data1= []
for i in index:
    shuping_sum = 0
    shoucang_sum = 0
    yingyang_sum = 0
    zishu_sum = 0
    for j in range(i,i+30):
        shuping_sum += data['总书评数'][j]
        shoucang_sum += data['当前被收藏数'][j]
        yingyang_sum += data['营养液数'][j]
        zishu_sum += data['全文字数'][j]
    data1.append([shuping_sum,shoucang_sum,yingyang_sum,zishu_sum])
data1 = pd.DataFrame(data1)
data1.columns=["总书评数","当前被收藏数","营养液数","全文字数"]
data1.to_excel('./src2/book_sub_rank.xlsx')
